<?php
    session_start();
    include_once '../../../../controlador/php/conexion/Conexion.php';
    $con = new Conexion();
    
    $toma = $_REQUEST['toma'];
    $oid = $_REQUEST['oid'];
    
    $count = "select count(*) as resp from lbseguimiento where hcnsolexa = ".$oid;
    $res = $con->query($count);
    
    while($res2 = mssql_fetch_array($res)){
      echo  $resp = $res2['resp'];
    }
    
    if($resp == '0'){
        
        $inser= "insert into lbseguimiento(hcnsolexa,segfectom,segestado,segrecibido,usu_oid,usu_oidr)values('".$oid."',GETDATE(),'1','','".$_SESSION['usuario']."','')";
        $con->query($inser);
    
    }else if($resp == "1"){
        
        $update ="update lbseguimiento
                    set segfectom = GETDATE(),
                    segestado = '$toma',
                    usu_oid ='".$_SESSION['usuario']."'
                  where hcnsolexa = '".$oid."'";
        $con->query($update);
    }
    
    
       
    $con->cerrarConexion();
    
 
?>

